using FireStarterModeller.BO;
using FireStarterModeller.Test.BO;
using Habanero.Testability;

namespace FireStarterModeller.Test
{
    public class TestUtilsDMLookupListSimple
    {
        public static BOTestFactory<DMLookupListSimple> GetBuilder()
        {
            return BOTestFactoryRegistry.Instance.Resolve<DMLookupListSimple>();
        }

        /// <summary>
        /// Creates a new saved DMLookupList with a random value assigned to every property
        /// </summary>
        public static DMLookupListSimple CreateSavedDMLookupListSimple()
        {
            DMLookupListSimple dMLookupList = CreateUnsavedValidDMLookupListSimple();
            dMLookupList.Save();
            return dMLookupList;
        }

        /// <summary>
        /// Creates a new unsaved DMLookupList with a valid value assigned to every property
        /// </summary>
        public static DMLookupListSimple CreateUnsavedValidDMLookupListSimple()
        {
            DMListItem unsavedValidDmListItem = TestUtilsDMListItem.CreateUnsavedValidDMListItem();
            return unsavedValidDmListItem.LookupListSimple;
        }
        /// <summary>
        /// Creates a new unsaved DMLookupList with a standard value assigned to every property
        /// </summary>
        public static DMLookupListSimple CreateUnsavedStandardDMLookupListSimple(DMProperty property)
        {
           DMLookupListSimple list = GetBuilder()
                .WithValue(simpleList => simpleList.DMProperty, property)
                .WithValue(simpleList => simpleList.Generated, true)
                .CreateValidBusinessObject();

           list.ListItems.Add(TestUtilsDMListItem.CreateUnsavedStandardDMListItem());
            return list;
        }

        /// <summary>
        /// Creates a new unsaved DMLookupList where all properties are null, except ID properties
        /// and those with default values.  If there are compulsory properties without
        /// defaults, saving the object will throw an exception.
        /// </summary>
        public static DMLookupListSimple CreateUnsavedDefaultDMLookupListSimple()
        {
            DMLookupListSimple dMLookupList = new DMLookupListSimple();
            return dMLookupList;
        }

        /// <summary>
        /// Creates a new saved DMLookupListSimple with a random value assigned to every property
        /// </summary>
        public static DMLookupListSimple CreateSavedDMSimpleLookupList_WithItems()
        {
            DMLookupListSimple dMLookupListSimple = CreateUnsavedValidDMLookupListSimple();
            DMListItem dmListItem = TestUtilsDMListItem.CreateUnsavedValidDMListItem();
            dMLookupListSimple.ListItems.Add(dmListItem);
            dMLookupListSimple.Save();
            return dMLookupListSimple;
        }
    }
}